QuickOPC User's Guide and Reference
Examples - User Interface - OPC Classic server dialog

.NET

// This example shows how to let the user browse for an OPC "Classic" server.

using System.Windows.Forms;
using OpcLabs.EasyOpc.Forms.Browsing;

namespace FormsDocExamples._OpcServerDialog
{
    static class ShowDialog
    {
        public static void Main1(IWin32Window owner)
        {
            var serverDialog = new OpcServerDialog();
            //serverDialog.Location = "";

            DialogResult dialogResult = serverDialog.ShowDialog(owner);
            if (dialogResult != DialogResult.OK)
                return;

            // Display results
            MessageBox.Show(owner, serverDialog.ServerElement);
        }
    }
}
# This example shows how to let the user browse for an OPC "Classic" server.

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcForms.dll"

$serverDialog = New-Object OpcLabs.EasyOpc.Forms.Browsing.OpcServerDialog
#$serverDialog.Location = ""

$dialogResult = $serverDialog.ShowDialog()
if ($dialogResult -ne [System.Windows.Forms.DialogResult]::OK) {
    return
}

# Display results
Write-Host $serverDialog.ServerElement
# This example shows how to let the user browse for an OPC "Classic" server.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from System.Windows.Forms import *
from OpcLabs.EasyOpc.Forms.Browsing import *


serverDialog = OpcServerDialog()
#serverDialog.Location = ''

dialogResult = serverDialog.ShowDialog()
print(dialogResult)
if dialogResult != DialogResult.OK:
    exit()

# Display results.
print('ServerElement: ', serverDialog.ServerElement, sep='')

COM

// This example shows how to let the user browse for an OPC "Classic" server.

class procedure ShowDialog.Main;
var
  ServerDialog: OpcLabs_EasyOpcForms_TLB._OpcServerDialog;
begin
  // Instantiate the dialog object
  ServerDialog := CoOpcServerDialog.Create;

  ServerDialog.ShowDialog(nil);

  // Display results
  WriteLn(ServerDialog.ServerElement.ToString);
end;
Rem This example shows how to let the user browse for an OPC "Classic" server.

Private Sub ShowDialog_Main_Command_Click()
    OutputText = ""

    ' Instantiate the dialog object
    Dim serverDialog As New OpcServerDialog
    Dim DialogResult
    DialogResult = serverDialog.ShowDialog
    
    OutputText = OutputText & DialogResult & vbCrLf
    If DialogResult <> 1 Then   ' OK
        Exit Sub
    End If
    
    ' Display results
    OutputText = OutputText & serverDialog.ServerElement & vbCrLf
End Sub
Rem This example shows how to let the user browse for an OPC "Classic" server.

Option Explicit

Const DialogResult_OK = 1

Dim ServerDialog: Set ServerDialog = CreateObject("OpcLabs.EasyOpc.Forms.Browsing.OpcServerDialog")
'ServerDialog.Location = ""
Dim dialogResult: dialogResult = ServerDialog.ShowDialog
WScript.Echo dialogResult

If dialogResult <> DialogResult_OK Then
    WScript.Quit
End If

' Display results
WScript.Echo ServerDialog.ServerElement

 

See Also

Conceptual